package cn.itsource.autoconfigure;


import cn.dev33.satoken.jwt.StpLogicJwtForSimple;
import cn.dev33.satoken.stp.StpLogic;
import cn.itsource.config.RedisConfig;
import cn.itsource.config.RedissonConfig;
import cn.itsource.config.SaTokenConfigure;
import cn.itsource.config.StpInterfaceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@Configuration
@Import({RedisConfig.class, RedissonConfig.class})
public class LoginAutoConfiguration {
    //层级bean 提到主配置类里面 也可以用import（加类.class）
    // Sa-Token 整合 jwt (Simple 简单模式)
    @Bean
    public StpLogic getStpLogicJwt() {
        return new StpLogicJwtForSimple();
    }
    @Bean
    public SaTokenConfigure getSaTokenConfigure(){
        return new SaTokenConfigure();
    }

    @Bean
    public StpInterfaceImpl getStpInterfaceImpl(RedisTemplate<String, Object> redisTemplate){
        return new StpInterfaceImpl(redisTemplate);
    }

    @Bean
    public PasswordEncoder passwordEncoder(){
        return new BCryptPasswordEncoder();
    }
}
